import request from './request.js'
import req from './req.js'

//登录
export const reqLogin = (userInfo) => request.post('login', userInfo)

//获取物流信息前登录
export const Login = (userInfo) => req.post('login', userInfo)

//获取左侧菜单
export const reqMenu = () => request.get('menus')

//获取用户数据列表
export const reqUserInfo = (queryInfo) => {
    return request({
        url: '/users',
        method: 'get',
        params: queryInfo
    })
}

//修改用户状态
export const updateUserStatus = (uId, type) => request.put(`users/${uId}/state/${type}`)

//添加用户
export const addUser = (userInfo) => request.post('users', userInfo)

//修改用户信息
export const updateUserInfo = (id, userInfo) => request.put(`users/${id}`, userInfo)

//删除用户
export const deleteUser = (id) => request.delete(`users/${id}`)

//获取list权限列表
export const reqRight = () => request.get('rights/list')

//获取tree权限列表
export const reqRightTree = () => request.get('rights/tree')

//获取角色列表
export const reqRole = () => request.get('roles')

//删除角色权限
export const deleteRoleRight = (roleId, rightId) => request.delete(`roles/${roleId}/rights/${rightId}`)

//添加角色
export const addRole = (roleInfo) => request.post('roles', roleInfo)

//删除角色
export const deleteRole = (id) => request.delete(`roles/${id}`)

//修改角色
export const updateRole = (id, roleInfo) => request.put(`roles/${id}`, roleInfo)

//角色授权
export const setRight = (roleId, checkedList) => request.post(`roles/${roleId}/rights`, checkedList)

//获取所有角色列表
export const getAllRole = () => request.get('roles')

//分配用户角色
export const setRole = (id, rid) => request.put(`users/${id}/role`, rid)

//获取商品分类
export const getCateList = (queryInfo) => request.get('categories', { params: queryInfo })

//获取父级分类数据列表
export const getParentCateList = () => request.get('categories', { params: { type: 2 } })

//添加分类
export const addCate=(addInfo)=>request.post('categories',addInfo)

//编辑分类
export const editCate=(id,cname)=>request.put(`categories/${id}`,cname)

//删除分类
export const deleteCate=(id)=>request.delete(`categories/${id}`)

//获取参数
export const getCateInfo=(id,type)=>request.get(`categories/${id}/attributes`,type)

//添加参数
export const addParams=(id,attrInfo)=>request.post(`categories/${id}/attributes`,attrInfo)

//根据id查询参数
export const getAttrById=(id,attrId,info)=>request.get(`categories/${id}/attributes/${attrId}`,info)

//编辑提交参数
export const addAttr=(id,attrId,info)=>request.put(`categories/${id}/attributes/${attrId}`,info)

//删除参数
export const deleteParams=(id,attrid)=>request.delete(`categories/${id}/attributes/${attrid}`)

//编辑提交参数
export const editParams=(id,attrId,paramsInfo)=>request.put(`categories/${id}/attributes/${attrId}`,paramsInfo)

//获取商品列表
export const getGoodsList=(info) =>request.get('goods',{params:info}) 

//删除商品
export const deleteGoods=(id)=>request.delete(`goods/${id}`)

//获取商品分类数据列表
export const getCategories=()=>request.get('categories')

//添加商品
export const addGoods=(goodsInfo)=>request.post('goods',goodsInfo)

//获取商品订单列表
export const getOrderList=(queryInfo)=>request.get('orders',queryInfo)

//查看物流信息
export const getLogistics=(id)=>req.get(`/kuaidi/${id}`) 

//获取基于时间统计的折线图
export const getGraph=()=>request.get('reports/type/1')